﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls"
    xmlns:primitives="clr-namespace:Microsoft.Phone.Controls.Primitives">

   <controls:NullToVisibilityConverter x:Name="NullToVisibilityConverter"/>

    <Style TargetType="controls:TransferControl" >
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:TransferControl">
                    <Border x:Name="TransferControl" Margin="0,0,0,12">
                        <controls:ContextMenuService.ContextMenu>
                            <controls:ContextMenu  IsEnabled="{Binding Path=IsContextMenuEnabled,RelativeSource={RelativeSource TemplatedParent}}">
                                <controls:MenuItem Header="cancel" x:Name="ContextMenuCancel"/>
                            </controls:ContextMenu>
                        </controls:ContextMenuService.ContextMenu>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="ControlStates">
                                <VisualState x:Name="Default">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.Visibility)" Storyboard.TargetName="TransferProgressBar">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="NoProgressBar" />
                                <VisualState x:Name="Hidden">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.Visibility)" Storyboard.TargetName="Root">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid x:Name="Root">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Image 
                                x:Name="Icon" 
                                Source="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Icon}" 
                                Stretch="UniformToFill"
                                Margin="0,0,18,0"
                                VerticalAlignment="Top"
                                MaxWidth="99"
                                MaxHeight="99"
                                Visibility="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Icon,Converter={StaticResource NullToVisibilityConverter}}"
                                />
                            <StackPanel VerticalAlignment="Top" Grid.Column="1" x:Name="ListItem">
                                <ContentControl 
                                    x:Name="Header" 
                                    Content="{TemplateBinding Header}" 
                                    ContentTemplate="{TemplateBinding HeaderTemplate}"
                                    FontFamily="{StaticResource PhoneFontFamilyNormal}"
                                    FontSize="{StaticResource PhoneFontSizeLarge}"
                                    Foreground="{StaticResource PhoneForegroundBrush}"
                                    Margin="0,-12,12,0"
                                    Padding="0"
                                    HorizontalAlignment="Left"
                                    IsTabStop="False"
                                    VerticalAlignment="Top"
                                    
                                    />
                                <ProgressBar  
                                    x:Name="TransferProgressBar"
                                    Value="{Binding Path=Monitor.BytesTransferred,RelativeSource={RelativeSource TemplatedParent},Mode=OneWay}"
                                    Minimum="0"
                                    Maximum="{Binding Path=Monitor.TotalBytesToTransfer,RelativeSource={RelativeSource TemplatedParent},Mode=OneWay}"
                                    IsIndeterminate="{Binding Path=Monitor.IsProgressIndeterminate,RelativeSource={RelativeSource TemplatedParent},Mode=OneWay,FallbackValue=False}"
                                    Visibility="Collapsed" 
                                    Style="{TemplateBinding ProgressBarStyle}"
                                    Margin="-12,4,36,4"
                                    />
                                <TextBlock 
                                    FontFamily="{StaticResource PhoneFontFamilySemiBold}"
                                    FontSize="12"
                                    Foreground="{TemplateBinding StatusTextBrush}">
                                    <TextBlock.Text>
                                        <Binding Path="Monitor.StatusText">
                                                <Binding.RelativeSource>
                                                <RelativeSource Mode="TemplatedParent" />
                                            </Binding.RelativeSource>
                                        </Binding>
                                    </TextBlock.Text>
                                </TextBlock>
                            </StackPanel>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="primitives:ToggleSwitchButton">
        <Setter Property="Background" Value="{StaticResource PhoneBackgroundBrush}"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="SwitchForeground" Value="{StaticResource PhoneAccentBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="primitives:ToggleSwitchButton">
                    <Border
                        x:Name="Root"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CacheMode="BitmapCache"
                        Opacity="{TemplateBinding Opacity}"
                        Padding="{TemplateBinding Padding}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ColorAnimation
                                            Storyboard.TargetName="SwitchBottom"
                                            Storyboard.TargetProperty="(Grid.Background).(SolidColorBrush.Color)"
                                            Duration="0"
                                            To="{StaticResource PhoneForegroundColor}"/>
                                        <ColorAnimation
                                            Storyboard.TargetName="ThumbCenter"
                                            Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
                                            Duration="0"
                                            To="{StaticResource PhoneForegroundColor}"/>
                                        <DoubleAnimation
                                            Storyboard.TargetName="Root"
                                            Storyboard.TargetProperty="Opacity"
                                            Duration="0"
                                            To="0.3"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CheckStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.05" To="Unchecked"/>
                                    <VisualTransition GeneratedDuration="0:0:0.05" To="Checked"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Checked">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="BackgroundTranslation"
                                            Storyboard.TargetProperty="(TranslateTransform.X)"
                                            Duration="0"
                                            To="69">
                                            <DoubleAnimation.EasingFunction>
                                                <ExponentialEase Exponent="15" EasingMode="EaseOut"/>
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                        <DoubleAnimation
                                            Storyboard.TargetName="ThumbTranslation"
                                            Storyboard.TargetProperty="(TranslateTransform.X)"
                                            Duration="0"
                                            To="69">
                                            <DoubleAnimation.EasingFunction>
                                                <ExponentialEase Exponent="15" EasingMode="EaseOut"/>
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Dragging"/>
                                <VisualState x:Name="Unchecked">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="BackgroundTranslation"
                                            Storyboard.TargetProperty="(TranslateTransform.X)"
                                            Duration="0"
                                            To="0"/>
                                        <DoubleAnimation
                                            Storyboard.TargetName="ThumbTranslation"
                                            Storyboard.TargetProperty="(TranslateTransform.X)"
                                            Duration="0"
                                            To="0"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid x:Name="SwitchRoot" Background="Transparent" Height="95" Width="136">
                            <Grid x:Name="SwitchTrack" Width="89">
                                <Grid x:Name="SwitchBottom" Background="{TemplateBinding SwitchForeground}" Height="34">
                                    <Rectangle
                                        x:Name="SwitchBackground"
                                        Fill="{TemplateBinding Background}"
                                        Width="77"
                                        Height="20"
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center">
                                        <Rectangle.RenderTransform>
                                            <TranslateTransform x:Name="BackgroundTranslation"/>
                                        </Rectangle.RenderTransform>
                                    </Rectangle>
                                    <Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="3">
                                        <Border BorderBrush="{StaticResource PhoneBackgroundBrush}" BorderThickness="4"/>
                                    </Border>
                                </Grid>
                                <Border
                                    x:Name="SwitchThumb"
                                    BorderBrush="{StaticResource PhoneBackgroundBrush}"
                                    BorderThickness="4,0"
                                    Margin="-4,0"
                                    Width="28"
                                    Height="38"
                                    HorizontalAlignment="Left">
                                    <Border.RenderTransform>
                                        <TranslateTransform x:Name="ThumbTranslation"/>
                                    </Border.RenderTransform>
                                    <Border
                                        x:Name="ThumbCenter"
                                        BorderBrush="{StaticResource PhoneForegroundBrush}"
                                        BorderThickness="2"
                                        Background="{StaticResource PhoneForegroundBrush}"/>
                                </Border>
                            </Grid>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:ToggleSwitch">
        <Setter Property="Background" Value="{StaticResource PhoneBackgroundBrush}"/>
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyLight}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="SwitchForeground" Value="{StaticResource PhoneAccentBrush}"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:ToggleSwitch">
                    <Border
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        Padding="{TemplateBinding Padding}"
                        CacheMode="BitmapCache">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="Header"
                                            Storyboard.TargetProperty="Opacity"
                                            Duration="0"
                                            To="0.3"/>
                                        <DoubleAnimation
                                            Storyboard.TargetName="Content"
                                            Storyboard.TargetProperty="Opacity"
                                            Duration="0"
                                            To="0.3"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid Margin="12,5,36,42">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <ContentControl
                                x:Name="Header"
                                Content="{TemplateBinding Header}"
                                ContentTemplate="{TemplateBinding HeaderTemplate}"
                                FontFamily="{StaticResource PhoneFontFamilyNormal}"
                                FontSize="{StaticResource PhoneFontSizeNormal}"
                                Foreground="{StaticResource PhoneSubtleBrush}"
                                HorizontalAlignment="Left"
                                IsTabStop="False"
                                Margin="-1,0,0,0"
                                Opacity="{TemplateBinding Opacity}"
                                VerticalAlignment="Bottom"/>
                            <ContentControl
                                x:Name="Content"
                                Grid.Row="1"
                                Content="{TemplateBinding Content}"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                IsTabStop="False"
                                Margin="-1,1,0,-7"
                                Opacity="{TemplateBinding Opacity}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            <primitives:ToggleSwitchButton
                                x:Name="Switch"
                                Grid.RowSpan="2"
                                Grid.Column="1"
                                Background="{TemplateBinding Background}"
                                Margin="-22,-29,-24,-28"
                                Opacity="{TemplateBinding Opacity}"
                                SwitchForeground="{TemplateBinding SwitchForeground}"
                                VerticalAlignment="Bottom"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:ContextMenu">
        <Setter Property="Padding" Value="0 18 0 28"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:ContextMenu">
                    <StackPanel x:Name="OuterPanel">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="VisibilityStates">
                                <VisualState x:Name="Open">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="ScaleX" Storyboard.TargetProperty="ScaleX">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="ScaleY" Storyboard.TargetProperty="ScaleY">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:.3" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:.42" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>

                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border1" Storyboard.TargetProperty="Opacity" To="1"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border2" Storyboard.TargetProperty="Opacity" To="1"/>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="Border1Reversed" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.4099" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.41" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="Border2Reversed" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.4099" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.41" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="OpenReversed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="ScaleX" Storyboard.TargetProperty="ScaleX">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="ScaleY" Storyboard.TargetProperty="ScaleY">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.42" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>

                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border1Reversed" Storyboard.TargetProperty="Opacity" To="1"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border2Reversed" Storyboard.TargetProperty="Opacity" To="1"/>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="Border1" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.4099" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.41" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="Border2" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.4099" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.41" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="OpenLandscape">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="ScaleX" Storyboard.TargetProperty="ScaleY">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="ScaleY" Storyboard.TargetProperty="ScaleX">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.42" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>

                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border1" Storyboard.TargetProperty="Opacity" To="1"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border2" Storyboard.TargetProperty="Opacity" To="1"/>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="Border1Reversed" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.4099" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.41" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="Border2Reversed" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.4099" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.41" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="OpenLandscapeReversed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="ScaleX" Storyboard.TargetProperty="ScaleY">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="ScaleY" Storyboard.TargetProperty="ScaleX">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.42" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>

                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border1Reversed" Storyboard.TargetProperty="Opacity" To="1"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border2Reversed" Storyboard.TargetProperty="Opacity" To="1"/>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="Border1" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.4099" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.41" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="0:0:0.42" Storyboard.TargetName="Border2" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.4099" Value="0"/>
                                            <LinearDoubleKeyFrame KeyTime="0:0:0.41" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Closed">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="ScaleX" Storyboard.TargetProperty="ScaleX" To="0"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="ScaleX" Storyboard.TargetProperty="ScaleY" To="0"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="ScaleY" Storyboard.TargetProperty="ScaleY" To="0"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="ScaleY" Storyboard.TargetProperty="ScaleX" To="0"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border1" Storyboard.TargetProperty="Opacity" To="0"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border2" Storyboard.TargetProperty="Opacity" To="0"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border1Reversed" Storyboard.TargetProperty="Opacity" To="0"/>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Border2Reversed" Storyboard.TargetProperty="Opacity" To="0"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <StackPanel.RenderTransform>
                            <ScaleTransform x:Name="ScaleX"/>
                        </StackPanel.RenderTransform>

                        <Rectangle MinWidth="2" MinHeight="2" Fill="{TemplateBinding BorderBrush}" x:Name="Border1"/>
                        <Rectangle MinWidth="2" MinHeight="2" Fill="{TemplateBinding Background}" x:Name="Border2"/>
                        <Grid x:Name="InnerGrid" Background="{TemplateBinding Background}">
                            <Grid.RenderTransform>
                                <ScaleTransform x:Name="ScaleY"/>
                            </Grid.RenderTransform>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <ItemsPresenter Margin="{TemplateBinding Padding}" Grid.Row="1"/>
                        </Grid>
                        <Rectangle MinWidth="2" MinHeight="2" Fill="{TemplateBinding Background}" x:Name="Border1Reversed"/>
                        <Rectangle MinWidth="2" MinHeight="2" Fill="{TemplateBinding BorderBrush}" x:Name="Border2Reversed"/>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:MenuItem">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneBackgroundBrush}"/>
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiLight}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}"/>
        <Setter Property="Padding" Value="25 10 0 10"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:MenuItem">
                    <Grid Background="{TemplateBinding Background}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" Storyboard.TargetName="Presenter" Storyboard.TargetProperty="Opacity" To="0.5"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentPresenter
                            x:Name="Presenter"
                            Content="{TemplateBinding Header}"
                            ContentTemplate="{TemplateBinding HeaderTemplate}"
                            Margin="{TemplateBinding Padding}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:Separator">
        <Setter Property="Background" Value="{StaticResource PhoneBackgroundBrush}"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Margin" Value="20 4 20 4"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:Separator">
                    <Border
                        BorderThickness="{TemplateBinding BorderThickness}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        Background="{TemplateBinding Background}"
                        Height="3"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="primitives:LoopingSelector">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border Background="Transparent">
                        <Canvas x:Name="ItemsPanel">
                            <Canvas.RenderTransform>
                                <TransformGroup>
                                    <TranslateTransform x:Name="CenteringTransform"/>
                                    <TranslateTransform x:Name="PanningTransform"/>
                                </TransformGroup>
                            </Canvas.RenderTransform>
                        </Canvas>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:LongListSelector">
        <Setter Property="Background" Value="{StaticResource PhoneBackgroundBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <primitives:TemplatedListBox x:Name="TemplatedListBox" 
                                                 Background="{TemplateBinding Background}">
                        <primitives:TemplatedListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                            </Style>
                        </primitives:TemplatedListBox.ItemContainerStyle>
                    </primitives:TemplatedListBox>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="primitives:LoopingSelectorItem">
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="Padding" Value="6"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border x:Name="root" Opacity="0" CacheMode="BitmapCache" Background="Transparent" Padding="{TemplateBinding Padding}">

                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">

                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.2"/>
                                </VisualStateGroup.Transitions>

                                <VisualState x:Name="Normal"/>

                                <VisualState x:Name="Expanded">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                                        <DoubleAnimation Storyboard.TargetName="background" Storyboard.TargetProperty="Opacity" To="0" Duration="0"/>
                                        <DoubleAnimation Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Opacity" To=".6" Duration="0"/>
                                    </Storyboard>
                                </VisualState>

                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="root" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                                        <DoubleAnimation Storyboard.TargetName="background" Storyboard.TargetProperty="Opacity" To="1" Duration="0"/>
                                    </Storyboard>
                                </VisualState>

                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Border.RenderTransform>
                            <TranslateTransform x:Name="Transform"/>
                        </Border.RenderTransform>

                        <Grid>
                            <Rectangle x:Name="background" Margin="2" Opacity="0" Fill="{StaticResource PhoneInactiveBrush}" CacheMode="BitmapCache"/>

                            <Border BorderThickness="2" BorderBrush="{StaticResource PhoneInactiveBrush}">
                                <ContentPresenter x:Name="contentPresenter" CacheMode="BitmapCache"/>
                            </Border>
                        </Grid>

                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:DatePicker">
        <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="PickerPageUri" Value="/Microsoft.Phone.Controls.Toolkit;component/DateTimePickers/DatePickerPage.xaml"/>
        <!-- For RTL, the pattern needs to be reversed -->
        <!--<Setter Property="ValueStringFormat" Value="{}{0:d}"/>-->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:DatePicker">
                    <StackPanel>
                        <ContentControl
                            Content="{TemplateBinding Header}"
                            ContentTemplate="{TemplateBinding HeaderTemplate}"
                            Foreground="{StaticResource PhoneSubtleBrush}"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            Margin="12,0,12,-4"/>
                        <Button
                            x:Name="DateTimeButton"
                            Content="{TemplateBinding ValueString}"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            FontFamily="{TemplateBinding FontFamily}"
                            Foreground="{TemplateBinding Foreground}"
                            Height="72"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:TimePicker">
        <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="PickerPageUri" Value="/Microsoft.Phone.Controls.Toolkit;component/DateTimePickers/TimePickerPage.xaml"/>
        <!-- Ideally, the short time pattern 't' would be correct. However, it does not respect
             the system's "24-hour clock" setting override and so the correct effective value of
             ValueStringFormat is determined on an as-needed basis (unless overridden). -->
        <!--<Setter Property="ValueStringFormat" Value="{}{0:t}"/>-->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:TimePicker">
                    <StackPanel>
                        <ContentControl
                            Content="{TemplateBinding Header}"
                            ContentTemplate="{TemplateBinding HeaderTemplate}"
                            Foreground="{StaticResource PhoneSubtleBrush}"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            Margin="12,0,12,-4"/>
                        <Button
                            x:Name="DateTimeButton"
                            Content="{TemplateBinding ValueString}"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            FontFamily="{TemplateBinding FontFamily}"
                            Foreground="{TemplateBinding Foreground}"
                            Height="72"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:ListPicker">
        <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="Margin" Value="{StaticResource PhoneTouchTargetOverhang}"/>
        <Setter Property="PickerPageUri" Value="/Microsoft.Phone.Controls.Toolkit;component/ListPicker/ListPickerPage.xaml"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:ListPicker">
                    <StackPanel>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="PickerStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Highlighted">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="Border"
                                            Storyboard.TargetProperty="Background"
                                            Duration="0">
                                            <DiscreteObjectKeyFrame
                                                Value="{StaticResource PhoneTextBoxEditBackgroundColor}"
                                                KeyTime="0"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="Border"
                                            Storyboard.TargetProperty="BorderBrush"
                                            Duration="0">
                                            <DiscreteObjectKeyFrame
                                                Value="{StaticResource PhoneTextBoxEditBorderBrush}"
                                                KeyTime="0"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="Border"
                                            Storyboard.TargetProperty="Background"
                                            Duration="0">
                                            <DiscreteObjectKeyFrame
                                                Value="{StaticResource TransparentBrush}"
                                                KeyTime="0"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="Border"
                                            Storyboard.TargetProperty="BorderBrush"
                                            Duration="0">
                                            <DiscreteObjectKeyFrame
                                                Value="{StaticResource PhoneDisabledBrush}"
                                                KeyTime="0"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="UserControl"
                                            Storyboard.TargetProperty="Foreground"
                                            Duration="0">
                                            <DiscreteObjectKeyFrame
                                                Value="{StaticResource PhoneDisabledBrush}"
                                                KeyTime="0"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentControl
                            Content="{TemplateBinding Header}"
                            ContentTemplate="{TemplateBinding HeaderTemplate}"
                            Foreground="{StaticResource PhoneSubtleBrush}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            Margin="0 0 0 8"/>
                        <Grid>
                            <Border x:Name="Border"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}">
                                <UserControl x:Name="UserControl" Foreground="{TemplateBinding Foreground}">
                                    <StackPanel>
                                        <TextBlock x:Name="MultipleSelectionModeSummary" Margin="8 8 0 8" />
                                        <Canvas x:Name="ItemsPresenterHost" MinHeight="46">
                                            <ItemsPresenter x:Name="ItemsPresenter">
                                                <ItemsPresenter.RenderTransform>
                                                    <TranslateTransform x:Name="ItemsPresenterTranslateTransform"/>
                                                </ItemsPresenter.RenderTransform>
                                            </ItemsPresenter>
                                        </Canvas>
                                    </StackPanel>
                                </UserControl>
                            </Border>
                        </Grid>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:ListPickerItem">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="8 10"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:ListPickerItem">
                    <Grid Background="{TemplateBinding Background}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected"/>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetName="ContentContainer"
                                            Storyboard.TargetProperty="Foreground"
                                            Duration="0">
                                            <DiscreteObjectKeyFrame
                                                Value="{StaticResource PhoneAccentBrush}"
                                                KeyTime="0"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentControl
                            x:Name="ContentContainer"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            Margin="{TemplateBinding Padding}"/> <!--Foreground="{TemplateBinding Foreground}"-->
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:AutoCompleteBox">
        <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <ContentControl Content="{Binding}" Margin="8,7"/>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Padding" Value="6,0,6,4"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:AutoCompleteBox">
                    <Grid>
                        <TextBox
                            x:Name="Text"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            FontFamily="{TemplateBinding FontFamily}"
                            FontSize="{TemplateBinding FontSize}"
                            FontStyle="{TemplateBinding FontStyle}"
                            FontWeight="{TemplateBinding FontWeight}"
                            Foreground="{TemplateBinding Foreground}"
                            InputScope="{TemplateBinding InputScope}"
                            Opacity="{TemplateBinding Opacity}"
                            Padding="{TemplateBinding Padding}"
                            Style="{TemplateBinding TextBoxStyle}"/>
                        <Popup x:Name="Popup">
                            <ListBox
                                x:Name="Selector"
                                Background="White"
                                BorderBrush="{StaticResource PhoneTextBoxEditBorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                FontFamily="{TemplateBinding FontFamily}"
                                FontSize="{TemplateBinding FontSize}"
                                FontStyle="{TemplateBinding FontStyle}"
                                FontWeight="{TemplateBinding FontWeight}"
                                Foreground="{TemplateBinding Foreground}"
                                IsTabStop="False"
                                ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                                ItemTemplate="{TemplateBinding ItemTemplate}"
                                Opacity="{TemplateBinding Opacity}"
                                Padding="0,8"/>
                        </Popup>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:TransitionFrame">
        <Setter Property="Background" Value="{StaticResource PhoneBackgroundBrush}"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:TransitionFrame">
                    <Border
                        x:Name="ClientArea"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        Margin="{TemplateBinding Margin}">
                        <Grid>
                            <ContentPresenter
                                x:Name="FirstContentPresenter"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            <ContentPresenter
                                x:Name="SecondContentPresenter"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:PerformanceProgressBar">
        <Setter Property="IsIndeterminate" Value="False"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/>
        <Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
        <Setter Property="IsHitTestVisible" Value="False"/>
        <Setter Property="Padding" Value="{StaticResource PhoneHorizontalMargin}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:PerformanceProgressBar">
                    <ProgressBar
                        Name="EmbeddedProgressBar"
                        Foreground="{TemplateBinding Foreground}"
                        Background="{TemplateBinding Background}"
                        IsIndeterminate="{TemplateBinding ActualIsIndeterminate}"
                        Padding="{TemplateBinding Padding}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="VisibilityStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.25" To="Normal"/>
                                    <VisualTransition GeneratedDuration="0:0:0.75" To="Hidden"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Hidden">
                                    <Storyboard>
                                        <DoubleAnimation To="0" 
                                                         Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                         Storyboard.TargetName="EmbeddedProgressBar" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ProgressBar.Template>
                            <ControlTemplate TargetType="ProgressBar">
                                <primitives:RelativeAnimatingContentControl HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                                    <primitives:RelativeAnimatingContentControl.Resources>
                                        <ExponentialEase EasingMode="EaseOut" Exponent="1" x:Key="ProgressBarEaseOut"/>
                                        <ExponentialEase EasingMode="EaseIn" Exponent="1" x:Key="ProgressBarEaseIn"/>
                                    </primitives:RelativeAnimatingContentControl.Resources>
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Determinate"/>
                                            <VisualState x:Name="Indeterminate">
                                                <Storyboard Duration="00:00:04.4" RepeatBehavior="Forever">
                                                    <ObjectAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="Visibility"
                                            Storyboard.TargetName="IndeterminateRoot">
                                                        <DiscreteObjectKeyFrame
                                                KeyTime="0">
                                                            <DiscreteObjectKeyFrame.Value>
                                                                <Visibility>Visible</Visibility>
                                                            </DiscreteObjectKeyFrame.Value>
                                                        </DiscreteObjectKeyFrame>
                                                    </ObjectAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0" Storyboard.TargetProperty="X" Storyboard.TargetName="R1TT">
                                                        <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
                                                        <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
                                                        <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
                                                        <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="X" Storyboard.TargetName="R2TT">
                                                        <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
                                                        <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
                                                        <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
                                                        <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="X" Storyboard.TargetName="R3TT">
                                                        <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
                                                        <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
                                                        <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
                                                        <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="X" Storyboard.TargetName="R4TT">
                                                        <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
                                                        <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
                                                        <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
                                                        <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="X" Storyboard.TargetName="R5TT">
                                                        <LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
                                                        <EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
                                                        <LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
                                                        <EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R1">
                                                        <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
                                                        <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R2">
                                                        <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
                                                        <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R3">
                                                        <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
                                                        <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R4">
                                                        <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
                                                        <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R5">
                                                        <DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
                                                        <DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
                                                    </DoubleAnimationUsingKeyFrames>
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Border x:Name="IndeterminateRoot" Margin="{TemplateBinding Padding}">
                                        <Grid HorizontalAlignment="Left">
                                            <Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R1" Opacity="0" CacheMode="BitmapCache">
                                                <Rectangle.RenderTransform>
                                                    <TranslateTransform x:Name="R1TT"/>
                                                </Rectangle.RenderTransform>
                                            </Rectangle>
                                            <Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R2" Opacity="0" CacheMode="BitmapCache">
                                                <Rectangle.RenderTransform>
                                                    <TranslateTransform x:Name="R2TT"/>
                                                </Rectangle.RenderTransform>
                                            </Rectangle>
                                            <Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R3" Opacity="0" CacheMode="BitmapCache">
                                                <Rectangle.RenderTransform>
                                                    <TranslateTransform x:Name="R3TT"/>
                                                </Rectangle.RenderTransform>
                                            </Rectangle>
                                            <Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R4" Opacity="0" CacheMode="BitmapCache">
                                                <Rectangle.RenderTransform>
                                                    <TranslateTransform x:Name="R4TT"/>
                                                </Rectangle.RenderTransform>
                                            </Rectangle>
                                            <Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R5" Opacity="0" CacheMode="BitmapCache">
                                                <Rectangle.RenderTransform>
                                                    <TranslateTransform x:Name="R5TT"/>
                                                </Rectangle.RenderTransform>
                                            </Rectangle>
                                        </Grid>
                                    </Border>
                                </primitives:RelativeAnimatingContentControl>
                            </ControlTemplate>
                        </ProgressBar.Template>
                    </ProgressBar>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <controls:TileSizeToWidthConverter x:Key="WidthConverter" />
    <controls:TileSizeToHeightConverter x:Key="HeightConverter" />

    <Style TargetType="controls:HubTile">
        <Style.Setters>
            <Setter Property="Height" Value="173"/>
            <Setter Property="Width" Value="173"/>
            <Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
            <Setter Property="Foreground" Value="#FFFFFFFF"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:HubTile">
                        <Border x:Name="Container"
                                Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource WidthConverter}}"
                                Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}}">
                            <Border.Resources>
                                <CubicEase EasingMode="EaseOut" x:Key="HubTileEaseOut"/>
                            </Border.Resources>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="ImageStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition x:Name="ExpandedToSemiexpanded" 
                                                          From="Expanded" To="Semiexpanded"
                                                          GeneratedDuration="0:0:0.85">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" 
                                                                               Storyboard.TargetName="TitlePanel">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=-1}" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.85" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=-0.4566}" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="RotationX" 
                                                                               Storyboard.TargetName="ViewportProjection">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="0.0" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition x:Name="SemiexpandedToExpanded" 
                                                          From="Semiexpanded" To="Expanded"
                                                          GeneratedDuration="0:0:0.85">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" 
                                                                               Storyboard.TargetName="TitlePanel">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=-0.4566}" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.85" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=-1}" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition x:Name="SemiexpandedToCollapsed" 
                                                          From="Semiexpanded" To="Collapsed"
                                                          GeneratedDuration="0:0:0.85">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" 
                                                                               Storyboard.TargetName="TitlePanel">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=-0.4566}" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.85" Value="0.0" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition x:Name="CollapsedToExpanded" 
                                                          From="Collapsed" To="Expanded"
                                                          GeneratedDuration="0:0:0.85">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" 
                                                                               Storyboard.TargetName="TitlePanel">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="0.0" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.85" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=-1}" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition x:Name="ExpandedToFlipped" 
                                                          From="Expanded" To="Flipped"
                                                          GeneratedDuration="0:0:0.85">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" 
                                                                               Storyboard.TargetName="TitlePanel">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=-1}" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                               Storyboard.TargetName="Image">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0.185" Value="Collapsed"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                               Storyboard.TargetName="BackPanel">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0.185" Value="Visible"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="RotationX" 
                                                                               Storyboard.TargetName="ViewportProjection">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="0.0" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.85" Value="180.0" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition x:Name="FlippedToExpanded" 
                                                          From="Flipped" To="Expanded"
                                                          GeneratedDuration="0:0:0.85">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" 
                                                                               Storyboard.TargetName="TitlePanel">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=-1}" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                               Storyboard.TargetName="Image">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0.185" Value="Visible"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                               Storyboard.TargetName="BackPanel">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0.185" Value="Collapsed"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="RotationX" 
                                                                               Storyboard.TargetName="ViewportProjection">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="180.0" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.85" Value="360.0" EasingFunction="{StaticResource HubTileEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                    </VisualStateGroup.Transitions>
                                    <VisualStateGroup.States>
                                        <VisualState x:Name="Expanded">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" To="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=-1}" 
                                                                 Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" 
                                                                 Storyboard.TargetName="TitlePanel"/>
                                                <DoubleAnimation Duration="0" To="0.0" 
                                                                 Storyboard.TargetProperty="RotationX" 
                                                                 Storyboard.TargetName="ViewportProjection"/>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                               Storyboard.TargetName="Image">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Semiexpanded">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" To="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=-0.4566}" 
                                                                 Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" 
                                                                 Storyboard.TargetName="TitlePanel"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Collapsed"/>
                                        <VisualState x:Name="Flipped">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" To="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=-1}" 
                                                                 Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" 
                                                                 Storyboard.TargetName="TitlePanel"/>
                                                <DoubleAnimation Duration="0" To="180.0" 
                                                                 Storyboard.TargetProperty="RotationX" 
                                                                 Storyboard.TargetName="ViewportProjection"/>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                               Storyboard.TargetName="Image">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Collapsed"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                                               Storyboard.TargetName="BackPanel">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup.States>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <StackPanel x:Name="Viewport"
                                    Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource WidthConverter}}"
                                    Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}}">
                                <StackPanel.Projection>
                                    <PlaneProjection CenterOfRotationY="0.25" x:Name="ViewportProjection"/>
                                </StackPanel.Projection>
                                <Grid x:Name="TitlePanel"
                                    RenderTransformOrigin="0.5,0.5"
                                    Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource WidthConverter}}"
                                    Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}, ConverterParameter=2}">
                                    <Grid.RenderTransform>
                                        <CompositeTransform/>
                                    </Grid.RenderTransform>
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Border Grid.Row="0"                                        
                                        Background="{TemplateBinding Background}">
                                        <TextBlock VerticalAlignment="Bottom"
                                               Margin="10,0,0,6"
                                               Text="{TemplateBinding Title}"
                                               FontFamily="{StaticResource PhoneFontFamilyNormal}"
                                               FontSize="41"
                                               Foreground="{TemplateBinding Foreground}"
                                               TextWrapping="NoWrap" 
                                               LineStackingStrategy="BlockLineHeight"
                                               LineHeight="39">
                                        </TextBlock>
                                    </Border>
                                    <Grid x:Name="BackPanel"
                                      Grid.Row="1"   
                                      Background="{TemplateBinding Background}"
                                      Visibility="Collapsed"
                                      Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource WidthConverter}}"
                                      Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}}">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Grid.Projection>
                                            <PlaneProjection CenterOfRotationY="0.5" RotationX="180"/>
                                        </Grid.Projection>
                                        <TextBlock x:Name="NotificationBlock" Grid.Row="0"
                                               Margin="8,8,0,6"
                                               Text="{TemplateBinding Notification}"
                                               FontFamily="{StaticResource PhoneFontFamilyNormal}"
                                               FontSize="{StaticResource PhoneFontSizeLarge}"
                                               Foreground="{TemplateBinding Foreground}"
                                               TextWrapping="NoWrap"
                                               LineStackingStrategy="BlockLineHeight"
                                               LineHeight="32"/>
                                        <TextBlock x:Name="MessageBlock" Grid.Row="0"
                                               Margin="10,10,10,6"
                                               Text="{TemplateBinding Message}"
                                               FontFamily="{StaticResource PhoneFontFamilyNormal}"
                                               FontSize="{StaticResource PhoneFontSizeNormal}"
                                               Foreground="{TemplateBinding Foreground}"
                                               TextWrapping="Wrap"
                                               LineStackingStrategy="BlockLineHeight"
                                               LineHeight="23.333"/>
                                        <TextBlock x:Name="BackTitleBlock" Grid.Row="1" 
                                               VerticalAlignment="Bottom" 
                                               Margin="10,0,0,6"
                                               FontFamily="{StaticResource PhoneFontFamilySemiBold}"
                                               FontSize="{StaticResource PhoneFontSizeNormal}"
                                               Foreground="{TemplateBinding Foreground}"
                                               TextWrapping="NoWrap"/>
                                    </Grid>
                                    <Border x:Name="Image" Grid.Row="1"
                                        Background="{TemplateBinding Background}">
                                        <Image
                                           Stretch="UniformToFill"
                                           Source="{TemplateBinding Source}"
                                           Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource WidthConverter}}"
                                           Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Size, Converter={StaticResource HeightConverter}}"/>
                                    </Border>
                                </Grid>
                            </StackPanel>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
    </Style>

    <Style TargetType="controls:MultiselectList">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:MultiselectList">
                    <ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" 
                                  BorderThickness="{TemplateBinding BorderThickness}" 
                                  Background="{TemplateBinding Background}" 
                                  Foreground="{TemplateBinding Foreground}" 
                                  Padding="{TemplateBinding Padding}">
                        <ItemsPresenter/>
                    </ScrollViewer>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:MultiselectItem">
        <Style.Setters>
            <Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:MultiselectItem">
                        <Grid MinHeight="52">
                            <Grid.Resources>
                                <ExponentialEase EasingMode="EaseIn" Exponent="8" x:Key="ExponentialEaseIn"/>
                                <QuadraticEase EasingMode="EaseOut" x:Key="QuadraticEaseOut"/>
                            </Grid.Resources>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="SelectionEnabledStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition x:Name="ClosedToExposed" 
                                                          From="Closed" To="Exposed"
                                                          GeneratedDuration="0:0:0.30">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                                               Storyboard.TargetName="OutterHintPanel">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="0.0" EasingFunction="{StaticResource QuadraticEaseOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.30" Value="1.0" EasingFunction="{StaticResource QuadraticEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition x:Name="ExposedToClosed" 
                                                          From="Exposed" To="Closed"
                                                          GeneratedDuration="0:0:0.30">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                                               Storyboard.TargetName="OutterHintPanel">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="1.0" EasingFunction="{StaticResource QuadraticEaseOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.30" Value="0.0" EasingFunction="{StaticResource QuadraticEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition x:Name="ExposedToOpened"
                                                          From="Exposed" To="Opened"
                                                          GeneratedDuration="0:0:0.30">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" 
                                                                               Storyboard.TargetName="SelectBox">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="-58" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="0" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" 
                                                                               Storyboard.TargetName="Presenter">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="24" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="86" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                                               Storyboard.TargetName="OutterHintPanel">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="1.0" EasingFunction="{StaticResource QuadraticEaseOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.30" Value="0.0" EasingFunction="{StaticResource QuadraticEaseOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" 
                                                                               Storyboard.TargetName="SelectBox">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0.0" Value="Visible"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" 
                                                                               Storyboard.TargetName="OutterHintPanel">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="False"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" 
                                                                               Storyboard.TargetName="InnerHintPanel">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="False"/>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition x:Name="ClosedToOpened"
                                                          From="Closed" To="Opened"
                                                          GeneratedDuration="0:0:0.15">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" 
                                                                               Storyboard.TargetName="SelectBox">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="-58" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="0" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" 
                                                                               Storyboard.TargetName="Presenter">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="24" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="86" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" 
                                                                               Storyboard.TargetName="SelectBox">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0.0" Value="Visible"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" 
                                                                               Storyboard.TargetName="OutterHintPanel">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="False"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" 
                                                                               Storyboard.TargetName="InnerHintPanel">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="False"/>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition x:Name="OpenedToClosed"
                                                          From="Opened" To="Closed"
                                                          GeneratedDuration="0:0:0.15">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" 
                                                                               Storyboard.TargetName="SelectBox">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="0" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="-58" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" 
                                                                               Storyboard.TargetName="Presenter">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="86" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="24" EasingFunction="{StaticResource ExponentialEaseIn}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" 
                                                                               Storyboard.TargetName="SelectBox">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0.15" Value="Collapsed"/>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                    </VisualStateGroup.Transitions>
                                    <VisualStateGroup.States>
                                        <VisualState x:Name="Closed"/>
                                        <VisualState x:Name="Exposed">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                                 Storyboard.TargetName="OutterHintPanel"
                                                                 Duration="0" To="1.0"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Opened">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" 
                                                                 Storyboard.TargetName="SelectBox"
                                                                 Duration="0" To="0"/>
                                                <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" 
                                                                 Storyboard.TargetName="Presenter"
                                                                 Duration="0" To="86"/>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" 
                                                                               Storyboard.TargetName="SelectBox">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" 
                                                                               Storyboard.TargetName="OutterCover">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                                 Storyboard.TargetName="OutterHintPanel"
                                                                 Duration="0" To="0.0"/>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" 
                                                                               Storyboard.TargetName="OutterHintPanel">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="False"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" 
                                                                               Storyboard.TargetName="InnerHintPanel">
                                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="False"/>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup.States>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Grid x:Name="OutterCover"
                                  HorizontalAlignment="Left" Width="86" 
                                  Visibility="Collapsed" Background="Transparent"/>
                            <Grid HorizontalAlignment="Stretch">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Grid Grid.Column="0" HorizontalAlignment="Stretch" primitives:ClipToBounds.IsEnabled="True">
                                    <ContentPresenter x:Name="Presenter">
                                        <ContentPresenter.RenderTransform>
                                            <CompositeTransform TranslateX="24"/>
                                        </ContentPresenter.RenderTransform>
                                    </ContentPresenter>
                                </Grid>
                                <Rectangle x:Name="InnerHintPanel" Grid.Column="0" Width="24"
                                           Height="{TemplateBinding HintPanelHeight}"
                                           HorizontalAlignment="Left"
                                           Fill="Transparent"
                                           StrokeThickness="0">
                                    <Rectangle.RenderTransform>
                                        <CompositeTransform TranslateX="24"/>
                                    </Rectangle.RenderTransform>
                                </Rectangle>
                                <ContentControl x:Name="InfoPresenter" Grid.Column="1" 
                                                VerticalAlignment="Top"
                                                Content="{TemplateBinding ContentInfo}"
                                                ContentTemplate="{TemplateBinding ContentInfoTemplate}"/>
                            </Grid>
                            <Rectangle x:Name="OutterHintPanel" Width="24"
                                       HorizontalAlignment="Left"
                                       Height="{TemplateBinding HintPanelHeight}"
                                       Fill="{TemplateBinding Background}"
                                       StrokeThickness="0" Opacity="0.0"/>
                            <Canvas HorizontalAlignment="Left">
                                <CheckBox x:Name="SelectBox" VerticalAlignment="Top" Margin="12,-20,5,0" Visibility="Collapsed"
                                          IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsSelected, Mode=TwoWay}">
                                    <CheckBox.RenderTransform>
                                        <CompositeTransform TranslateX="-58"/>
                                    </CheckBox.RenderTransform>
                                </CheckBox>
                            </Canvas>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
    </Style>

    <Style TargetType="controls:ExpanderView">
        <Style.Setters>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <StackPanel/>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:ExpanderView">
                        <Grid>
                            <Grid.Resources>
                                <QuadraticEase EasingMode="EaseOut" x:Key="QuadraticEaseOut"/>
                                <QuadraticEase EasingMode="EaseInOut" x:Key="QuadraticEaseInOut"/>
                            </Grid.Resources>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="41"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="ExpansionStates">
                                    <VisualStateGroup.States>
                                        <VisualState x:Name="Collapsed">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetProperty="(FrameworkElement.Height)" 
                                                                 Storyboard.TargetName="ItemsCanvas"
                                                                 Duration="0" To="0"/>
                                                <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                                 Storyboard.TargetName="ItemsCanvas"
                                                                 Duration="0" To="0.0"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Expanded">
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetProperty="(FrameworkElement.Height)" 
                                                                 Storyboard.TargetName="ItemsCanvas" Duration="0"/>
                                                <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" 
                                                                 Storyboard.TargetName="ItemsCanvas"
                                                                 Duration="0" To="1.0"/>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup.States>
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition From="Collapsed" To="Expanded" 
                                                          GeneratedDuration="0:0:0.15">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="ItemsCanvas">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.00" Value="0" EasingFunction="{StaticResource QuadraticEaseOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="1" EasingFunction="{StaticResource QuadraticEaseOut}" x:Name="CollapsedToExpandedKeyFrame"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ItemsCanvas" Duration="0" To="1.0"/>
                                            </Storyboard>
                                        </VisualTransition>
                                        <VisualTransition From="Expanded" To="Collapsed" 
                                                          GeneratedDuration="0:0:0.15" >
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="ItemsCanvas">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.00" Value="1" EasingFunction="{StaticResource QuadraticEaseInOut}" x:Name="ExpandedToCollapsedKeyFrame"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="0" EasingFunction="{StaticResource QuadraticEaseInOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ItemsCanvas">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.00" Value="1.0" EasingFunction="{StaticResource QuadraticEaseInOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="0.0" EasingFunction="{StaticResource QuadraticEaseInOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)"
                                                                               Storyboard.TargetName="ItemsCanvas">
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.00" Value="0.0" EasingFunction="{StaticResource QuadraticEaseInOut}"/>
                                                    <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="-35" EasingFunction="{StaticResource QuadraticEaseInOut}"/>
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualTransition>
                                    </VisualStateGroup.Transitions>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ExpandabilityStates">
                                    <VisualState x:Name="Expandable"/>
                                    <VisualState x:Name="NonExpandable">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ExpandableContent">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0.0" Value="Collapsed"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="Line">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0.0" Value="Collapsed"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="NonExpandableContent">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0.0" Value="Visible"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <ListBoxItem x:Name="ExpandableContent" controls:TiltEffect.IsTiltEnabled="True"
                                         Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="2">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="41"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <ContentControl x:Name="Header"
                                                    HorizontalContentAlignment="Stretch"
                                                    HorizontalAlignment="Stretch"
                                                    Content="{TemplateBinding Header}"
                                                    ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                    Grid.Row="0" Grid.Column="0"
                                                    Grid.ColumnSpan="2"/>
                                    <ContentControl x:Name="Expander"                                            
                                                    Margin="11,0,0,0"
                                                    Grid.Row="1" Grid.Column="1"
                                                    HorizontalContentAlignment="Stretch"
                                                    HorizontalAlignment="Stretch"
                                                    Content="{TemplateBinding Expander}"
                                                    ContentTemplate="{TemplateBinding ExpanderTemplate}"/>
                                    <Grid x:Name="ExpanderPanel" Grid.Row="0" Grid.Column="0" 
                                          Grid.RowSpan="2" Grid.ColumnSpan="2" Background="Transparent"/>
                                </Grid>
                            </ListBoxItem>
                            <Line x:Name="Line" Grid.Row="1" Grid.Column="1"
                                  Grid.RowSpan="2"
                                  HorizontalAlignment="Left"
                                  Stroke="{StaticResource PhoneSubtleBrush}" 
                                  StrokeThickness="3" X1="0" Y1="0" X2="0" Y2="1"
                                  Stretch="Fill"/>
                            <ContentControl x:Name="NonExpandableContent"
                                            Grid.Row="0" Grid.Column="0" 
                                            Grid.RowSpan="2" Grid.ColumnSpan="2"
                                            Visibility="Collapsed"
                                            HorizontalAlignment="Stretch"
                                            HorizontalContentAlignment="Stretch"
                                            Content="{TemplateBinding NonExpandableHeader}"
                                            ContentTemplate="{TemplateBinding NonExpandableHeaderTemplate}"/>
                            <Canvas x:Name="ItemsCanvas" 
                                    Grid.Row="2" Grid.Column="1"
                                    Opacity="0.0" 
                                    Margin="11,0,0,0">
                                <ItemsPresenter x:Name="Presenter"/>
                                <Canvas.RenderTransform>
                                    <CompositeTransform TranslateY="0.0"/>
                                </Canvas.RenderTransform>
                            </Canvas>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
    </Style>

    <Style TargetType="controls:PhoneTextBox">
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
        <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource PhoneTextBoxBrush}"/>
        <Setter Property="SelectionBackground" Value="{StaticResource PhoneAccentBrush}"/>
        <Setter Property="SelectionForeground" Value="{StaticResource PhoneTextBoxSelectionForegroundBrush}"/>
        <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
        <Setter Property="Padding" Value="{StaticResource PhoneBorderThickness}"/>

        <Setter Property="Template">
            <Setter.Value>

                <ControlTemplate TargetType="controls:PhoneTextBox">

                    <Grid Background="Transparent" x:Name="RootGrid">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="HintBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="TextBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="TextBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Margin" Storyboard.TargetName="TextBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="0" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="HorizontalAlignment" Storyboard.TargetName="Text">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <HorizontalAlignment>Stretch</HorizontalAlignment>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="HintBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="white"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="HintBorder">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneTextBoxEditBorderBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="LengthIndicatorStates">
                                <VisualState x:Name="LengthIndicatorVisible">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="LengthIndicator">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
                                                                       Storyboard.TargetProperty="Margin">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                                    Value="0, 0, 0, 27" />
                                        </ObjectAnimationUsingKeyFrames>

                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="LengthIndicator">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="0.6"/>
                                        </ObjectAnimationUsingKeyFrames>

                                        <DoubleAnimation Storyboard.TargetName="LengthIndicator"
                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" 
                                                         To="32"
                                                         Duration="0:0:0.350">
                                            <DoubleAnimation.EasingFunction>
                                                <ExponentialEase Exponent="6" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="LengthIndicatorHidden">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="LengthIndicator"
                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" 
                                                         To="0"
                                                         Duration="0:0:0.350">
                                            <DoubleAnimation.EasingFunction>
                                                <ExponentialEase Exponent="6" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>

                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
                                                                       Storyboard.TargetProperty="Margin">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0"
                                                                    Value="0, 0, 0, 0" />
                                        </ObjectAnimationUsingKeyFrames>
                                        
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="LengthIndicator">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0.350" Value="0"/>
                                        </ObjectAnimationUsingKeyFrames>

                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="LengthIndicator">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0.350">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <Border x:Name="LengthIndicatorBorder">
                            <TextBlock  Foreground="{StaticResource PhoneContrastBackgroundBrush}"
                                        HorizontalAlignment="Right"
                                        TextAlignment="Right"
                                        VerticalAlignment="Bottom"
                                        Margin="{StaticResource PhoneMargin}"
                                        FontSize="{StaticResource PhoneFontSizeNormal}"
                                        Opacity="0"
                                        x:Name="LengthIndicator">
                                <TextBlock.RenderTransform >
                                    <TranslateTransform />
                                </TextBlock.RenderTransform>
                            </TextBlock>
                        </Border>

                        <Border x:Name="HintBorder" 
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                Margin="{StaticResource PhoneTouchTargetOverhang}">
                            <Grid>
                                <ContentControl x:Name="HintContent"
                                                Style="{TemplateBinding HintStyle}"
                                                Content="{TemplateBinding Hint}"
                                                Background="Transparent"
                                                HorizontalAlignment="Left"
                                                VerticalAlignment="Center"
                                                Margin="3,0,3,0"
                                                Visibility="{TemplateBinding ActualHintVisibility}"/>
                                <ContentControl x:Name="ContentElement"
                                                BorderThickness="0" 
                                                HorizontalContentAlignment="Stretch"
                                                Margin="{StaticResource PhoneTextBoxInnerMargin}"
                                                Padding="{TemplateBinding Padding}" 
                                                VerticalContentAlignment="Stretch"/>
                            </Grid>
                        </Border>
                        <Border x:Name="TextBorder"
                                BorderBrush="{StaticResource PhoneDisabledBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="Transparent" 
                                Margin="{StaticResource PhoneTouchTargetOverhang}"
                                Visibility="Collapsed">
                            <TextBox x:Name="Text"
                                     Foreground="{StaticResource PhoneDisabledBrush}"
                                     FontWeight="{TemplateBinding FontWeight}"
                                     FontStyle="{TemplateBinding FontStyle}"
                                     FontSize="{TemplateBinding FontSize}" 
                                     FontFamily="{TemplateBinding FontFamily}"
                                     SelectionForeground="{TemplateBinding SelectionForeground}"
                                     SelectionBackground="{TemplateBinding SelectionBackground}"
                                     TextAlignment="{TemplateBinding TextAlignment}"
                                     TextWrapping="{TemplateBinding TextWrapping}"
                                     Text="{TemplateBinding Text}"
                                     HorizontalAlignment="Left" />
                        </Border>
                        <Border x:Name="ActionIconBorder"
                                Width="84"
                                Height="72"
                                Background="Transparent"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Bottom">
                            <Image x:Name="ActionIcon"
                                    Width="26"
                                    Height="26"
                                    Source="{TemplateBinding ActionIcon}"/>
                        </Border>

                        <TextBlock x:Name="MeasurementTextBlock"
                                   Margin="8"
                                   IsHitTestVisible="False"
                                   Opacity="0"
                                   FontFamily="{TemplateBinding FontFamily}"
                                   FontSize="{TemplateBinding FontSize}"
                                   FontStretch="{TemplateBinding FontStretch}"
                                   TextAlignment="{TemplateBinding TextAlignment}"
                                   FontWeight="{TemplateBinding FontWeight}"
                                   FontStyle="{TemplateBinding FontStyle}"
                                   TextWrapping="{TemplateBinding TextWrapping}"
                                   Text="{TemplateBinding Text}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:CustomMessageBox">
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeNormal}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="Background" Value="{StaticResource PhoneChromeBrush}"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:CustomMessageBox">
                    <Grid 
                        Background="{TemplateBinding Background}"
                        HorizontalAlignment="Stretch">
                        <Grid 
                            Width="480"                                                       
                            HorizontalAlignment="Left">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <StackPanel 
                                Grid.ColumnSpan="2" 
                                Margin="0,0,0,18">
                                <TextBlock 
                                    x:Name="TitleTextBlock"
                                    Text="{TemplateBinding Title}" 
                                    Foreground="{TemplateBinding Foreground}"
                                    Visibility="Collapsed"
                                    Margin="24,16,24,-6"
                                    FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>
                                <TextBlock 
                                    x:Name="CaptionTextBlock"
                                    Text="{TemplateBinding Caption}"
                                    Foreground="{TemplateBinding Foreground}"
                                    Visibility="Collapsed"
                                    Margin="24,8,24,0"
                                    FontSize="{StaticResource PhoneFontSizeLarge}"                                    
                                    FontFamily="{StaticResource PhoneFontFamilySemiBold}"
                                    TextWrapping="Wrap"
                                    HorizontalAlignment="Left"/>
                                <TextBlock 
                                    x:Name="MessageTextBlock"
                                    Text="{TemplateBinding Message}"
                                    Foreground="{TemplateBinding Foreground}"
                                    Margin="24,11,24,0"
                                    Visibility="Collapsed"
                                    FontSize="{StaticResource PhoneFontSizeMedium}"
                                    FontFamily="{StaticResource PhoneFontFamilySemiLight}"                                                                        
                                    TextWrapping="Wrap"
                                    HorizontalAlignment="Left"/>
                                <ContentPresenter Margin="12,0,0,0"/>
                            </StackPanel>
                            <Button 
                                x:Name="LeftButton"  
                                Grid.Row="1" Grid.Column="0"
                                Content="{TemplateBinding LeftButtonContent}"
                                IsEnabled="{TemplateBinding IsLeftButtonEnabled}"
                                Foreground="{TemplateBinding Foreground}"
                                Margin="12,0,0,12"   
                                Visibility="Collapsed"                                                            
                                controls:TiltEffect.IsTiltEnabled="True"/>
                            <Button 
                                x:Name="RightButton"
                                Grid.Row="1" Grid.Column="1"
                                Content="{TemplateBinding RightButtonContent}"
                                IsEnabled="{TemplateBinding IsRightButtonEnabled}"
                                Foreground="{TemplateBinding Foreground}"
                                Margin="0,0,12,12"
                                Visibility="Collapsed"                             
                                controls:TiltEffect.IsTiltEnabled="True"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:Rating">

        <Setter Property="Background" Value="{StaticResource PhoneBackgroundBrush}" />
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}" />

        <!-- default width and height of native rating control, as seen in marketplace -->
        <Setter Property="Width" Value="215" />
        <Setter Property="Height" Value="43" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:Rating">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}" >
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="DragHelperStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition To="Visible"
                                                      GeneratedDuration="0:0:0.1" />
                                    <VisualTransition To="Collapsed"
                                                      GeneratedDuration="0:0:0.3" />
                                </VisualStateGroup.Transitions>

                                <VisualState x:Name="Collapsed" />

                                <VisualState x:Name="Visible">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="DragBorderElement"
                                                         Storyboard.TargetProperty="Opacity" To="1.0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid x:Name="Root" Background="Transparent">
                            <Border x:Name="DragBorderElement" 
                                        Background="{TemplateBinding Background}" 
                                        Width="35" Height="30" 
                                        HorizontalAlignment="Left" 
                                        VerticalAlignment="Top"
                                        Opacity="0">
                                <TextBlock x:Name="DragTextBlockElement" TextAlignment="Center" Text="3.5" />
                            </Border>
                            <Grid x:Name="UnfilledGridElement" />

                            <!-- layered on top of InactiveItems by being placed in 
                                 the same row, clipping mask determines how many 
                                 stars are displayed. The border is used to apply
                                 a clipping mask to the filled RatingItems -->
                            <Border x:Name="FilledClipElement">
                                <Grid x:Name="FilledGridElement" />
                            </Border>


                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <!-- can be used to specify attributes for the filled items such as
             custom fill or border. -->
        <Setter Property="FilledItemStyle">
            <Setter.Value>
                <Style TargetType="controls:RatingItem">
                    <Setter Property="Background" Value="{StaticResource PhoneForegroundBrush}" />
                </Style>
            </Setter.Value>
        </Setter>

        <!-- can be used to specify attributes for the unfilled items such as
             custom fill or border. -->
        <Setter Property="UnfilledItemStyle">
            <Setter.Value>
                <Style TargetType="controls:RatingItem">
                    <Setter Property="Background" Value="{StaticResource PhoneSubtleBrush}" />
                </Style>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- This style and control template define the layout for the RatingItems.
         It can be overriden to support arbitrary shapes or other UIElements. -->
    <Style TargetType="controls:RatingItem">
        <Setter Property="Margin" Value="2" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:RatingItem">
                    <Path 
                            Fill="{TemplateBinding Background}"
                            Stroke="{TemplateBinding BorderBrush}"
                            StrokeThickness="{TemplateBinding StrokeThickness}"
                            Stretch="Fill"
                            Data="F1 M 5.0,0.0 L 6.1,3.5 L 9.8,3.5 L 6.8,5.6 L 7.9,9.0 L 5.0,6.9 L 2.1,9.1 L 3.2,5.6 L 0.2,3.5 L 3.9,3.5 L 5.0,0.0 Z" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
